<?php

App::uses('AppModel', 'Model');

class Order extends AppModel {

    public $table = 'orders';
//////////////////////////////////////////////////
    public $actsAs = array('CakePtbr.AjusteData', 'CakePtbr.AjusteFloat', 'Search.Searchable');
    //``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``
    public $filterArgs = array(
        'id' => array('type' => 'value'),
        'first_name' => array('type' => 'like'),
        'last_name' => array('type' => 'like'),
        'email' => array('type' => 'like'),
        'phone' => array('type' => 'like'),
        'billing_address' => array('type' => 'like'),
        'billing_address2' => array('type' => 'like'),
        'billing_city' => array('type' => 'like'),
        'billing_zip' => array('type' => 'like'),
        'billing_state' => array('type' => 'like'),
        'billing_country' => array('type' => 'like'),
        'shipping_address' => array('type' => 'like'),
        'shipping_address2' => array('type' => 'like'),
        'shipping_city' => array('type' => 'like'),
        'shipping_zip' => array('type' => 'like'),
        'shipping_state' => array('type' => 'like'),
        'shipping_country' => array('type' => 'like'),
        'weight' => array('type' => 'like'),
        'order_item_count' => array('type' => 'like'),
        'subtotal' => array('type' => 'like'),
        'tax' => array('type' => 'like'),
        'shipping' => array('type' => 'like'),
        'total' => array('type' => 'like'),
        'order_type' => array('type' => 'like'),
        'authorization' => array('type' => 'like'),
        'transaction' => array('type' => 'like'),
        'status' => array('type' => 'like'),
        'ip_address' => array('type' => 'like'),
        'created' => array('type' => 'like'),
        'modified' => array('type' => 'like'),
    );
    public $validate = array(
        'name' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Name is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'email' => array(
            'email' => array(
                'rule' => array('email'),
                'message' => 'Email is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        /*        'phone' => array(
          'notempty' => array(
          'rule' => array('phone'),
          'message' => 'Phone is invalid',
          //'allowEmpty' => false,
          //'required' => true,
          //'last' => false, // Stop validation after this rule
          //'on' => 'create', // Limit validation to 'create' or 'update' operations
          ),
          ), */
        'billing_address' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Billing Address is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'billing_city' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Billing City is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'billing_state' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Billing State is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'shipping_address' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Shipping Address is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'shipping_city' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Shipping City is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'shipping_state' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Shipping State is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'creditcard_number' => array(
            'notempty' => array(
                'rule' => array('cc'),
                'message' => 'Credit Card Number is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'creditcard_code' => array(
            'rule1' => array(
                'rule' => array('notEmpty'),
                'message' => 'Credit Card Code is required',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
            'rule2' => array(
                'rule' => '/^[0-9]{3,4}$/i',
                'message' => 'Credit Card Code is invalid',
            //'allowEmpty' => false,
            //'required' => true,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
    );
//////////////////////////////////////////////////

    public $hasMany = array(
        'OrderItem' => array(
            'className' => 'OrderItem',
            'foreignKey' => 'order_id',
            'dependent' => true,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => '',
        )
    );

//////////////////////////////////////////////////
}
